/*
	GameClient.h

	This object is used to connect to an GameServer object over a Socket object
	(c)1999 Palestar, Richard Lyle
*/

#ifndef GAME_CLIENT_H
#define GAME_CLIENT_H

#include "World/WorldClient.h"
#include "GameContext.h"
#include "NounShip.h"
#include "GameDll.h"

//----------------------------------------------------------------------------

class DLL GameClient : public WorldClient, public GameContext::GameUser
{
public:
	DECLARE_WIDGET_CLASS();

	// Types
	class DLL UserGameClient : public WorldClient::UserWorldClient
	{
	public:
		virtual void	onShipDestroyed( Noun * pKiller );
		virtual void	onShipCaptured( Noun * pCapper );
		virtual void	onShipDetached();						// called when players ship is detached
		virtual void	onOrderReceived( NounShip::Order order, Noun * pTarget, Noun * pFrom );
	};

	static dword		sm_nVersion;

	// Construction
	GameClient();

	// WorldClient Interface
	virtual dword		version() const;
	virtual bool		prepWorld();
	virtual Noun *		validateNoun( Noun * pNoun );

	// WorldContext::User interface
	void				onChat( Noun * pNoun, const char * pMessage );
	void				onAttachNoun( Noun * pNoun );
	void				onDetachNoun( Noun * pNoun );

	// GameContext::GameUser interface
	void				onKill( Noun * pWho, Noun *pDead );
	void				onDestroyed( NounShip * pWho, Noun * pKiller );
	void				onDamageShip( Noun * pWho, float damage, Noun *pTarget );
	void				onCaptureShip( Noun * pWho, NounShip * pCaptured );
	void				onFriendlyFire( Noun * pWho, float damage );
	void				onPlanetsDamaged( Noun * pWho, float damage );
	void				onPlanetsCaptured( Noun * pWho, float amount );
	void				onRepair( Noun * pWho, float repair );
	void				onConstruct( Noun * pWho, float construct );
	void				onKamikaze( Noun * pWho, float damage );
	void				onSelfDestruct( NounShip * pWho );
	void				onJump( Noun * pWho );
	void				onCollidePlanet( Noun * pWho );
	void				onResourcesLost( Noun * pWho, float amount );
	void				onScout( Noun * pWho, float points );
	void				onBonusPrestige( Noun * pWho, float bonus );
	void				onCredits( Noun * pWho, int credits );

	void				onOrderReceived( NounShip * pWho, NounShip::Order order, 
							Noun * pTarget, Noun * pFrom );

	// Accessors
	GameContext *		gameContext() const;
};

//---------------------------------------------------------------------------------------------------

inline GameContext * GameClient::gameContext() const
{
	return WidgetCast<GameContext>( context() );
}

#endif

//----------------------------------------------------------------------------
// EOF
